package com.fau.om.action.index;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.fau.om.action.PublicAction;
import com.fau.om.entity.MedicalAdmin;
import com.fau.om.entity.MedicalOrders;
import com.opensymphony.xwork2.ModelDriven;


/**
 * @desc （平台的，组的，我的）订单审核Action
 * @author suny
 * @datetime 2014年9月15日,上午10:29:21
 */
@Controller
@Scope("prototype")
@ParentPackage("default")
@Namespace("/")
public class MyAuditAction extends PublicAction implements ModelDriven<MedicalOrders>{

	private static final long serialVersionUID = 1L;
	private MedicalOrders orders = new MedicalOrders();
	
	/**
	 * @desc 我的订单审核跳转-界面 
	 * @return
	 * @author suny
	 * @datetime 2014年9月15日,上午10:14:00
	 */
	@Action(value = "my_audit_init", results = {@Result(name = SUCCESS, location = "my_audit_init.jsp")})
	public String init(){
		return SUCCESS;
	}
	
	/**
	 * @desc 查询我的未审核订单
	 * @return
	 * @author suny
	 * @datetime 2014年9月15日,下午3:57:24
	 */
	@Action(value = "my_audit_view")
	public String view(){
		HttpServletResponse response = ServletActionContext.getResponse();
		map = ServletActionContext.getContext().getParameters();
		MedicalAdmin admin = (MedicalAdmin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		orders.setCheckUserId(admin.getId());
		pageBean = this.baseAllService.getAuditManagerService().findMyPendingOrders(orders, map);
		map.clear();
		map.put("total", pageBean.getTotalRow());
		map.put("data", pageBean.getResult());
		formatJSON(response, map);
		return null;
	}
	
	@Override
	public MedicalOrders getModel() {
		return orders;
	}
	
}
